cmake_minimum_required (VERSION 2.8)
project (libwren)

SET(CMAKE_TOOLCHAIN_FILE "d:/project/c++/vcpkg/scripts/buildsystems/vcpkg.cmake")

SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib)

# c99 support
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=c99 -D_GNU_SOURCE")

set(LIB_LIST)

INCLUDE_DIRECTORIES(src/include)
INCLUDE_DIRECTORIES(src/vm)
INCLUDE_DIRECTORIES(src/optional)
INCLUDE_DIRECTORIES(src/cli)
INCLUDE_DIRECTORIES(src/module)
file(GLOB_RECURSE DIR_SRCS1 "src/vm/*.c" "src/vm/*.h")
file(GLOB_RECURSE DIR_SRCS2 "src/optional/*.c" "src/optional/*.h")
file(GLOB_RECURSE DIR_SRCS3 "src/cli/*.c" "src/cli/*.h")
foreach (TMP_PATH ${DIR_SRCS3})
    string (FIND ${TMP_PATH} "src/cli/main.c" EXCLUDE_DIR_FOUND)
    if (NOT ${EXCLUDE_DIR_FOUND} EQUAL -1)
        list (REMOVE_ITEM DIR_SRCS3 ${TMP_PATH})
    endif ()
endforeach(TMP_PATH)
file(GLOB_RECURSE DIR_SRCS4 "src/module/*.c" "src/module/*.h")

# library
ADD_LIBRARY(wren STATIC ${DIR_SRCS1} ${DIR_SRCS2} ${DIR_SRCS3} ${DIR_SRCS4})
TARGET_LINK_LIBRARIES(wren ${LIB_LIST})